< previous page page_737 next page >

Page 737
Note.gif
In the examples here, you access relatively small datasets. If your ODBC interface requires the passing of very large datasets, you need to develop more sophisticated methods for storing and retrieving the resulting datasets. It is always a good idea to limit the size of the result set as much as possible, though, because passing large amounts of data over the ODBC link can adversely affect not just your Visual Basic program, but all programs that are using the same network.

The first high-level routine you build actually creates a dataset for your Visual Basic program. This routine handles the creation of the dataset by using all the properties that already have been set. This method is called right after the Connect method.
Create a new function called Refresh and add the code in Listing 19.11.
Type.gifListing 19.11. Coding the Refresh function.
Public Function Refresh()
    '
    ' collect data from result set
    '
    Dim intResult As Integer
    Dim intCols As Integer
    Dim intRows As Integer
    Dim strBuffer As String * BUFFERLEN
    Dim strItem As String
    Dim strData As String
    Dim lngOutLen As Long
    Dim intLoop As Integer

    '
    ' run the query
    intResult = ExecDirect
    If intResult <> sqlSuccess Then
        Refresh = sqlerr
        Exit Function
    End If
    '
    ' get the column count
    intResult = NumResultCols(intCols)
    If intCols = 0 Then
        Refresh = sqlerr
        Exit Function
    Else
        NumCols = intCols
    End If
    '
    ' set up for collection
    frmSQLData.rtbSQlData = ""
continues

 
< previous page page_737 next page >

If you like this book, buy it!